from selenium import webdriver
# from selenium.webdriver.chrome.service import Service as ChromeService # 在旧版中不需要显式创建Service对象

chrome_driver_path = "/Users/promoriarty/PycharmProjects/xuexi-crawler/chromedriver-mac-x64/chromedriver"

print(f"尝试使用指定的 ChromeDriver 路径: {chrome_driver_path}")

try:
    # 旧版 Selenium 直接将 executable_path 传递给 Chrome 构造函数
    driver = webdriver.Chrome(executable_path=chrome_driver_path) # 不传递 options
    print("WebDriver 初始化成功 (旧版方式)!")
    driver.get("https://www.google.com")
    print(f"页面标题: {driver.title}")
    driver.quit()
except Exception as e:
    print(f"WebDriver 初始化或操作失败 (旧版方式)。错误: {e}")
    import traceback
    traceback.print_exc()